#!/usr/bin/python3
# -*- coding:utf-8 -*-
# Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
# This file is a part of the CANN Open Software.
# Licensed under CANN Open Software License Agreement Version 1.0 (the "License").
# Please refer to the License for details. You may not use this file except in compliance with the License.
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
# See LICENSE in the root of the software repository for the full text of the License.
# ======================================================================================================================

import os
import numpy as np


def gen_golden_data_simple():
    """
    生成用于自定义 sqrt 算子验证的输入数据和金标准输出数据。
    - 输入数据从 [1, 4) 的均匀分布中采样，形状为 (1024, 1024)，数据类型为 float16。
    - 输出数据为输入数据的平方根，类型同样为 float16。
    - 输入保存到 ./input/input_x.bin，金标准保存到 ./output/golden.bin。
    """

    # 数据类型和形状设置
    dtype = np.float16
    output_shape = (1024, 1024)

    # 可选：设定随机种子，便于结果复现
    np.random.seed(0)

    # 生成输入数据
    input_x = np.random.uniform(1, 4, output_shape).astype(dtype)

    # 计算平方根作为金标准
    golden = np.sqrt(input_x).astype(dtype)

    # 创建输入输出目录（更安全、跨平台）
    os.makedirs("input", exist_ok=True)
    os.makedirs("output", exist_ok=True)

    # 保存数据到文件
    input_x.tofile("./input/input_x.bin")
    golden.tofile("./output/golden.bin")


if __name__ == "__main__":
    gen_golden_data_simple()
